/********************************************************************
* Copyright (c) 2012,TGS,All rights reserved.
* fileName:	MeasureDialog.h	
* created:	2013/10/10 13:16

* version:	1.6
*********************************************************************/

#pragma once

#include "ui_measurebase.h"

class QCloseEvent;

namespace TGS{
namespace GeoMath{

	class Point;
}
}


namespace TGS{
namespace MapControl{

class MeasureTool;

class MeasureDialog : public QDialog, private Ui::MeasureBase
{
    Q_OBJECT
	typedef TGS::GeoMath::Point Point;
public:
    //! Constructor
    MeasureDialog(MeasureTool* tool, Qt::WFlags f = 0 );
public:
    //! Save position
    void saveWindowLocation( void );

    //! Restore last window position/size
    void restorePosition( void );

    //! Add new point
    void addPoint(const Point &point );

    //! Mose move
    void mouseMove(const Point &point );

    //! Mouse press
    void mousePress(const Point &point );

 public slots:
    //! Reject
    void on_buttonBox_rejected( void );

    //! Reset and start new
    void restart();

    //! Close event
    void closeEvent( QCloseEvent *e );
private:

    //! formats distance to most appropriate units
    QString formatDistance( double distance );

    //! formats area to most appropriate units
    QString formatArea( double area );

    //! shows/hides table, shows correct units
    void updateUi();

    double _total;

    //! indicates whether we're measuring distances or areas
    bool _measureArea;

    //! Number of decimal places we want.
    int _decimalPlaces;

    //! pointer to measure tool which owns this dialog
    MeasureTool* _tool;
};


}//MapControl
}//TGS
